

#include "huaweicloud/sdrs/v1/model/ListProtectionGroupsResponse.h"

namespace HuaweiCloud {
namespace Sdk {
namespace Sdrs {
namespace V1 {
namespace Model {




ListProtectionGroupsResponse::ListProtectionGroupsResponse()
{
    serverGroupsIsSet_ = false;
    count_ = 0;
    countIsSet_ = false;
}

ListProtectionGroupsResponse::~ListProtectionGroupsResponse() = default;

void ListProtectionGroupsResponse::validate()
{
}

web::json::value ListProtectionGroupsResponse::toJson() const
{
    web::json::value val = web::json::value::object();

    if(serverGroupsIsSet_) {
        val[utility::conversions::to_string_t("server_groups")] = ModelBase::toJson(serverGroups_);
    }
    if(countIsSet_) {
        val[utility::conversions::to_string_t("count")] = ModelBase::toJson(count_);
    }

    return val;
}

bool ListProtectionGroupsResponse::fromJson(const web::json::value& val)
{
    bool ok = true;
    
    if(val.has_field(utility::conversions::to_string_t("server_groups"))) {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("server_groups"));
        if(!fieldValue.is_null())
        {
            std::vector<ShowProtectionGroupParams> refVal;
            ok &= ModelBase::fromJson(fieldValue, refVal);
            setServerGroups(refVal);
        }
    }
    if(val.has_field(utility::conversions::to_string_t("count"))) {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("count"));
        if(!fieldValue.is_null())
        {
            int32_t refVal;
            ok &= ModelBase::fromJson(fieldValue, refVal);
            setCount(refVal);
        }
    }
    return ok;
}

std::vector<ShowProtectionGroupParams>& ListProtectionGroupsResponse::getServerGroups()
{
    return serverGroups_;
}

void ListProtectionGroupsResponse::setServerGroups(const std::vector<ShowProtectionGroupParams>& value)
{
    serverGroups_ = value;
    serverGroupsIsSet_ = true;
}

bool ListProtectionGroupsResponse::serverGroupsIsSet() const
{
    return serverGroupsIsSet_;
}

void ListProtectionGroupsResponse::unsetserverGroups()
{
    serverGroupsIsSet_ = false;
}

int32_t ListProtectionGroupsResponse::getCount() const
{
    return count_;
}

void ListProtectionGroupsResponse::setCount(int32_t value)
{
    count_ = value;
    countIsSet_ = true;
}

bool ListProtectionGroupsResponse::countIsSet() const
{
    return countIsSet_;
}

void ListProtectionGroupsResponse::unsetcount()
{
    countIsSet_ = false;
}

}
}
}
}
}


